package tp.pr5;

/**
 * This class represents the city where the robot is wandering. 
 * It contains information about the streets and the places in the city.
 * 
 */

public class City 
{
	
	private Street[] cityMap;
	
	/**
	 * Default constructor
	 */
	public City()
	{
		
	}
	
	/**
	 * Creates a city using an array of streets
	 * 
	 * @param cityMap
	 */
	
	public City(Street[] cityMap)
	{
		this.cityMap = cityMap;
	}
	
	/**
	 * Looks for the street that starts from the given place in the given direction.
	 * 
	 * @param currentPlace The place where to look for the street
	 * @param currentHeading The direction to look for the street
	 * 
	 * @return the street that stars from the given place in the given direction. 
	 * It returns null if there is not any street in this direction from the given place
	 */
	
	public Street lookForStreet(Place currentPlace, Direction currentHeading)
	{	
		if(cityMap != null)
		{
			for (int i = 0; i < cityMap.length; i++)
			{
				if(cityMap[i].comeOutFrom(currentPlace, currentHeading))
				{
					return cityMap[i];
				}
			}
		}
		
		return null;

	}
	
	/**
	 * Adds an street to the city
	 * 
	 * @param street
	 */
	
	public void addStreet(Street street)
	{
		Street[] _street = new Street[0];
		
		this.cityMap = _street;
	}
	
}
